终于搞懂Livecd的制作了,从此可以任意定制livecd工具了 您所在的位置:网站首页 linux 制作iso镜像 终于搞懂Livecd的制作了,从此可以任意定制livecd工具了

终于搞懂Livecd的制作了,从此可以任意定制livecd工具了

2024-01-21 16:19| 来源: 网络整理| 查看: 265

制作Livecd步骤:

1、写ks文件;

例如:

lang en_GB.UTF-8 keyboard us timezone Asia/Shanghai --isUtc #selinux --enforcing selinux --disabled #firewall --enabled --service=cockpit firewall --disabled #xconfig --startxonboot services --enabled=sshd # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part / --size 8192 --fstype ext4 part /boot/efi --fstype="ext4" --size=200 part /boot --fstype="ext4" --size=1024 part swap --fstype="swap" --size=2048 part /run/initramfs/live --fstype="ext4" --grow --size=1 # Root password auth --useshadow --enablemd5 rootpw --plaintext ROOTPassWorD repo --name=base --baseurl=http://mirrors.ustc.edu.cn/centos/7.9.2009/os/x86_64/ repo --name=updates --baseurl=http://mirrors.ustc.edu.cn/centos/7/updates/x86_64/ repo --name=extras --baseurl=http://mirrors.ustc.edu.cn/centos/7/extras/x86_64/ repo --name=epel --baseurl=http://mirrors.aliyun.com/epel/7/x86_64 %packages @core kernel bash openssh-server shim #支持uefi启动,必须的包 grub2 #支持uefi启动,必须的包 grub2-efi #支持uefi启动,必须的包 grub2-tools #支持uefi启动,必须的包 grub2-efi-x64-cdboot #支持uefi启动,必须的包 efibootmgr #支持uefi启动,必须的包 unzip vim net-tools %end %post %end

2、使用livecd-creator创建livecd镜像:  

#安装livecd-tools #yum -y install livecd-tools #制作livecd ISO镜像文件 #livecd-creator --verbose -c centos7-livecd.ks --cache=cache -f centos7-livecd

命令执行成功后,会在当前目录下生成一个iso文件;

安装定制工具,或修改一些文件: 3、挂载iso镜像,将iso文件下的所有文件拷贝到一个其他位置;

#mount -o loop centos-livecd.iso /mnt #cp -rp /mnt/* /newiso/

4、将/LiveCD/squashfs.img文件拷贝至一个新位置;

#cp /newiso/LiveOS/squashfs.img /workpath/

4、解压squashfs.imge文件:

#安装squashfs-tools #yum -y install squashfs-tools #cd /workpath #unsquashfs squashfs.img

解压成功后当前目录下会产生一个目录squashfs-root 5、挂载squashfs-root/LiveCD/ext3fs到一个目录下;

#mount -o loop squash-root/LiveOS/ext3fs.img /media/

6、chroot到挂载的目录下,进行安装软件;

#chroot /media/

chroot到/media/之后,安装定制工具,或修改这里的文件;

注意:安装板卡驱动或打内核模块时,一定保证制作livecd的系统内核版本与livecdISO里工具要求的内核版本一致,否则安装的内核模块或板卡驱动肯能不能正常使用。

PS:设置Livecd系统自动使用root用户登录,避免手动登录,也可以添加开机自运行脚本

修改文件/usr/lib/systemd/system/[email protected]

[Service] # the VT is cleared by TTYVTDisallocate # ExecStart=-/sbin/agetty --noclear %I $TERM # 将上面内容修改为如下内容 ExecStart=-/sbin/agetty --autologin root --noclear %I

7、安装后,删除没必要的文件,重新打包squashfs.img

#cd /workpath #mksquashfs squashfs-root/ squashfs.img -comp xz

8、将新的squashfs.img拷贝到livcd镜像文件的LiveCD目录下;

#rm -fr /newiso/LiveOS/squashfs.img #cp /workpath/squashfs.img /newiso/LiveOS/squashfs.img

9、到LivCD文件所在的目录下使用genisoimagem或mkisofs重新打包iso镜像;

#genisoimage -v -cache-inodes -joliet-long -R -J -T -V MyLiveCD -o /databackup/MyLiveCD_v1.0.iso -c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul -boot-load-size 4 -boot-info-table -eltorito-alt-boot -bisolinux/efiboot.img -no-emul-boot -allow-limited-size . 或 #mkisofs -R -b isolinux/isolinux.bin -c isolinux/boot.cat -o /tmp/MyLiveCD_v6.0.iso -V "LiveCD" -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -bisolinux/efiboot.img -no-emul-boot -allow-limited-size . -V后跟的label要与EFI/BOOT/grub.cfg文件里的label一致,否则系统启动时找不到硬盘;

参考文章:

CentOS 7 Live-CD 的制作 - 八戒的技术博客

定制化LiveCD_weixin_34255055的博客-CSDN博客

CentOS7实现开机自动登录_centos7 自动登录_@码小白的博客-CSDN博客



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有